#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include<stdlib.h>
#include<string.h>

int main(int argc, char *argv[]){
    //打开文件只读
    int fp=open("test.txt",O_RDONLY);

    char *buf=malloc(sizeof(char)*1024);
    
    
    
    while ((read(fp,buf,1024))>0)
    {   
        printf("read %ld bytes\n",strlen(buf));
        write(STDOUT_FILENO,buf,strlen(buf));
        
    }
    free(buf);
    close(fp);
    return 0;

}